package com.example.stmp.Mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.stmp.Entity.Department;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DepartmentMapper {

    // 添加部门
    void insert(Department department);

    //查询部门数
    @Select("select count(*) from department")
    int count();

    //根据id查询部门名称
    @Select("select depart_name from department where depart_id = #{id}")
    String selectDepartNameById(Long id);


    //根据id查询部门
    @Select("select * from department where depart_id = #{id} and status = 1")
    Department selectDepartInfoById(Long id);

    //查询所有部门信息
    @Select("select * from department")
    List<Department> selectDepartInfo();

    //更新部门信息
    void update(Department department);

    //查询部门状态
    @Select("select status from department where depart_id = #{id}")
    int selectDepartStatusById(Long id);

    //修改部门状态
    @Update("update department set status = #{status} where depart_id = #{id}")
    void updateDepartStatus(Long id, int status);

    //查询部门数量
    @Select("select count(*) from department where status = 1")
    Long selectcount();

    //分页查询部门信息
    @Select("select * from department limit #{startIndex}, #{pageSize}")
    List<Department> pageQuery(Integer startIndex, Integer pageSize);
}
